<template>
	<view>
		<view class="" style="background-color: #f3f4f6;;">
			<view class="top">
				<view class="top-info">
					<van-row class="demo-van-row">
						<van-col :span="2">
							<view class="" style="width: 100%;height: 2rpx;">
								
							</view>
						</van-col>
					    <van-col :span="6">
							
					        <view class="top_left">
					        	<view class="top_image" @click="cellclick('用户信息')">
					        		<image :src="userInfo.avatarUrl" mode=""></image>
					        	</view>
								
								
					        </view>
					    </van-col>
						<van-col :span="2">
							<text style="font-size: 76rpx; line-height: 136rpx;">|</text>
						</van-col>
					    <van-col :span="14">
							<view class="top_right">
								<view class="" style="margin-top: 16rpx;">
									<text style="font-weight: bolder; font-size: 50rpx; ">{{userInfo.nickName}}</text>
								</view>
								
								<view class="tips" style="position: relative; bottom: 0rpx;">
									<van-icon v-if="userInfo.gender==1" size="32rpx"  name="cloud://cu4oral6-9g3l2orjbb347b4c.6375-cu4oral6-9g3l2orjbb347b4c-1307874055/性别男.png" />
									<van-icon v-else size="32rpx"  name="cloud://cu4oral6-9g3l2orjbb347b4c.6375-cu4oral6-9g3l2orjbb347b4c-1307874055/性别女.png" />
									<text style=" font-size: 28rpx;color: #555555;">悠然见南山</text>
								</view>
							</view>
					    </van-col>
					</van-row>
				</view>
				
				
			</view>	
		</view>
		
		
		<view class="body">
			<!-- cell组件 Icon组件 -->
			<van-cell :icon="item.img" v-for="(item,index) in btns" size="large" is-link link-type="navigateTo" :url="item.url" @click="cellclick(item.title)">
			  <view slot="title">
			    <view class="van-cell-text">{{item.title}}</view>
			  </view>
			</van-cell>
			<!-- <van-panel v-for="(item,index) in btns" @click="btnsclick($event)" :data-url="item.url" isFull="true">
				<van-row>
					<van-col :span="2"><image class="body-image" :src="item.img" mode=""></image></van-col>
					<van-col :span="21" ><text style="font-size: 36rpx;line-height: 52rpx;">{{item.title}}</text></van-col>
					<van-col :span="1"><i class="m-font m-font-arrow-right">	</i></van-col>
				</van-row>
			</van-panel> -->
			
			
			
		</view>
	</view>
</template>

<script>
	import Page from '../../common/page';
	export default {
		data() {
			return {
				token:null,
				userInfo:{
					name:"cU4oral6",topimage:"https://tva1.sinaimg.cn/crop.548.144.424.424.180/bb70fc68jw8faa3ha8qktj21400p0tpo.jpg?KID=imgbed,tva&Expires=1635838399&ssig=cGmptsFNbR",txt:"同谓之玄，玄之又玄，众妙之门"
				},
				btns:[
					{img:"service-o",title:"账户设置",url:"/pages/details/details"},
					{img:"service-o",title:"我创建的签到",url:"/pages/user_sign/user_sign"},
					{img:"service-o",title:"联系客服",url:"联系客服"},
					{img:"manager-o",title:"关于我们",url:"关于我们"},
					{img:"failure",title:"bug反馈",url:"bug反馈"},
					{img:"failure",title:"使用说明",url:"bug反馈"},
					{img:"replay",title:"重新登录",url:"bug反馈"}
					]
			}
		},
		methods: {
			//页面跳转
			cellclick(a){
				console.log(a)
				if(a=='重新登录')
				{
					uni.removeStorage({
					    key: 'token',
					    success: function (res) {
					        uni.redirectTo({
					        	url:"../welcome/welcome"
					        })
					    }
					});
				}else if(a=='用户信息'){
					uni.navigateTo({
					    url: '../details/details'
					});
				}
			},
			//从缓存获取用户昵称与头像
			getinfo(){
				try {
				    const token = uni.getStorageSync('token');
					const userInfo = uni.getStorageSync('userInfo');
					console.log("获取信息成功")
				    if (token) {
				        this.token = token;
				    }
					if(userInfo){
						this.userInfo = userInfo;
						console.log(userInfo)
					}
					
					//获取用户信息
					uni.request({
					    url: this.apiurl + '/user/user_info', //仅为示例，并非真实接口地址。
					    header: {
					        'Authorization': uni.getStorageSync('token') //自定义请求头信息
					    },
					    success: (res) => {
							console.log(res.data)
					        if(res.data.data.oneAdministrator){
								// console.log(1111)
								// this.btns.concat({img:"service-o",title:"管理员功能",url:"/pages/admin/admin"})
								this.btns.push({img:"service-o",title:"管理员功能",url:"/pages/admin/admin"})
							}
							
							
					    }
					});
				} catch (e) {
				    // error
				}
			}
		},
		onLoad() {
			//获取用户信息
			this.getinfo();
			//获取登陆状态
			this.checkLogin();
			// uni.redirectTo({url:'/pages/welcome/welcome'})
			// this.aginLogin();
			
		}
	}
</script>


<style>
.top{
	
	/* padding: 10%; */
	height: 298rpx;
	/* border-bottom: 2rpx solid #808080; */
	/* width: 90%; */
	/* margin: 5%; */
	background-image: url("../../static/bg.webp");
	background-position: center center;
	background-size: cover;
	background-repeat: no-repeat;
}
.top-info{
	height: 136rpx;
	border-top-left-radius: 42rpx;
	border-top-right-radius: 42rpx;
	background-color: rgba(255, 255, 255, 0.6);
	position: absolute;
	top:170rpx;
	width: 100%;
}
.top_image{
	width: 100%;
	border-radius: 50%;/* 
	border: 2rpx solid #007AFF; */
}
image{
	margin-top: 8rpx;
	width: 120rpx;
	height:120rpx ;
	border-radius: 50%;
	/* border: 2rpx solid #007AFF; */
}
.body{
	/* margin-top: 10rpx; */
	border-top: #f3f4f6 20rpx solid;
	font-size: 32rpx !important;
	/* margin: 5%; */
}
.m-font-arrow-right {
	display: inline-block;
	border-top: 4rpx solid;
	border-right: 4rpx solid;
	width: 20rpx;
	height: 20rpx;
	border-color: #EA6000;
	transform: rotate(45deg);
	/* margin: 100rpx auto auto 200rpx; */
}
.body-image{
	width: 40rpx;
	height: 36rpx;
}
.tips image{
	margin: 0;
}
.van-cell{
	font-size: 32rpx !important;
}
</style>
